var status = 0;
var selStr;
var sel;
var selitem;
var fail = ["你是认真的吗……？", "我在画画，可以不要一直防碍我吗？", "请不要这样，你会困扰我的。"];

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(e, c, b) {
    var a = cm.getMapId() - 744000000;
    if (a < 0 || a > 16) {
        cm.dispose();
        return
    }
    if (status == 0 && e == 0) {
        cm.dispose();
        return
    }
    if (e == 1) {
        status++
    } else {
        status--
    }
    if (status == 0) {
        var f = eim.getProperty("map_" + a);
        if (f != null && f.equals("clear")) {
            cm.sendOk("嘻嘻，我已经答应你了。你先去下一间教室吧！");
            cm.dispose()
        } else {
            selStr = "喔？来这边有什么事吗？#b\r\n";
            selStr += "#L1#那个……你有喜欢的人吗？#l\r\n";
            selStr += "#L2#我喜欢你#l\r\n";
            selStr += "#L3#跟我交往吧！！#l\r\n";
            selStr += "#L4#这样的感觉是第一次，最近看到你都心跳加快……#l\r\n";
            cm.askMenu(selStr)
        }
    } else {
        if (status == 1) {
            if (b == randomNum(1, 4)) {
                cm.sendOk("这样啊……事实上我也……我们交往看看。")
            } else {
                cm.sendOk(fail[randomNum(0, fail.length - 1)]);
                cm.dispose()
            }
        } else {
            if (status == 2) {
                var d = Math.min(15, eim.getNumberProperty("state"));
                cm.fieldEffect_ScreenMsg("Map/Effect.img/MapleHighSchool/clear");
                cm.gainExp(1000 * d * cm.getPlayer().getLevel());
                cm.gainItem(4310105, parseInt(d * cm.getPlayer().getLevel() / 10));
                eim.setProperty("map_" + a, "clear");
                cm.dispose()
            }
        }
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
};